<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="myschool.util.MybatisUtil" %>
<%@ page import="myschool.entity.Student" %>
<%@ page import="java.util.List" %>
<%@ page import="myschool.dao.GradeDao" %>
<%@ page import="myschool.entity.Grade" %>
<%@ page import="myschool.dao.SubjectDao" %>
<%@ page import="myschool.entity.Subject" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div>
    <a href="addSubject.jsp"> <input type="button" value="添加新课程"></a>
</div>

<table border="1">
    <%
        SqlSession s = MybatisUtil.get();
        SubjectDao mapper = s.getMapper(SubjectDao.class);

        List<Subject> subjects = mapper.paging(1, 10);
        MybatisUtil.close(s);
        for (Subject subject : subjects) {
    %>
    <tr>
        <td><%=subject.getId()%>
        </td>
        <td><%=subject.getSubjectname()%>
        </td>
        <td><%=subject.getClasshour()%>
        </td>
        <td><%=subject.getGradeid()%>
        </td>
        <td><a href="updateSubject.jsp?id=<%=subject.getId()%>">编辑</a>
            &nbsp;&nbsp;
        <a onclick="return confirm('真的要删除这门课?')" href="delsubject.jsp?id=<%=subject.getId()%>">删除</a></td>
    </tr>
    <%}%>
</table>
</body>
</html>
